package cn.com.nes.site.action.crm;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.service.crm.AnalysisCusService;

@Controller("analysisCus")
@RequestMapping("/analysisCus")
public class AnalysisoCusAction {
	
	@Resource
	private AnalysisCusService service;
	
	//查询线索列表
	@RequestMapping(method = RequestMethod.POST, value = "/getTotalCustomer")
	public @ResponseBody  PageData getTotalCustomer(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getTotalCustomer(req) ;
			return res;
	}
	//查询客户地区分布
	@RequestMapping(method = RequestMethod.POST, value = "/getCustomerDistribution")
	public @ResponseBody  PageData getCustomerDistribution(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getCustomerDistribution(req) ;
			return res;
	}
	//查询客户级别占比
	@RequestMapping(method = RequestMethod.POST, value = "/getCustomerLevelPer")
	public @ResponseBody  PageData getCustomerLevelPer(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getCustomerLevelPer(req) ;
			return res;
	}
	
	//签单区域排行
	@RequestMapping(method = RequestMethod.POST, value = "/getCustomerOpp")
	public @ResponseBody  PageData getCustomerOpp(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getCustomerOpp(req) ;
			return res;
	}
	
	//客户平均拜访时长
		@RequestMapping(method = RequestMethod.POST, value = "/getCustomerClaim")
		public @ResponseBody  PageData getCustomerClaim(HttpServletRequest request,
				HttpServletResponse response, ModelMap modelMap) throws Exception {
				DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
				PageData res = new PageData() ;
				if (req_Status.getRetCode() != 0) {
					res = new PageData();
					res.setRetCode(req_Status.getRetCode()) ;
					res.setRetMessage(req_Status.getRetMessage());
					return res;
				}	
				DataReq req = req_Status.getReq() ;
				res = service.getCustomerClaim(req) ;
				return res;
		}
}
